﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style type="text/css">
        .draggablePanel { width: 16em; padding: 0 1em; }
        .draggablePanel ul li { margin: 1em 0; padding: 0.5em 0; }
        .draggablePanel ul li span.ui-icon { float: left; }
        .draggablePanel ul li span.count { font-weight: bold; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:Panel ID="Panel1" runat="server" CssClass="draggablePanel ui-widget-content"
        Height="200px" Width="200px">
        <p>
            Drag me to trigger the chain of events.</p>
        <ul class="ui-helper-reset">
            <li class="ui-state-default ui-corner-all" id="event-start"><span class="ui-icon ui-icon-play">
            </span>"start" invoked <span class="count">0</span>x</li>
            <li class="ui-state-default ui-corner-all" id="event-drag"><span class="ui-icon ui-icon-arrow-4">
            </span>"drag" invoked <span class="count">0</span>x</li>
            <li class="ui-state-default ui-corner-all ui-state-hover" id="event-stop"><span class="ui-icon ui-icon-stop">
            </span>"stop" invoked <span class="count">0</span>x</li>
        </ul>
    </asp:Panel>
    <DotNetAge:Draggable ID="Draggable1" runat="server" OnClientDrag="counts[1]++;updateCounterStatus($drag_counter,counts[1]);"
        OnClientDragStart="counts[0]++;updateCounterStatus($start_counter,counts[0]);"
        OnClientDragStop="counts[2]++;updateCounterStatus($stop_counter,counts[2]);">
        <Target TargetID="Panel1" />
    </DotNetAge:Draggable>

    <script type="text/javascript">
        var counts = [0, 0, 0];
        var $start_counter;
        $().ready(function() {
            $start_counter = $('#event-start'), $drag_counter = $('#event-drag'), $stop_counter = $('#event-stop');
            
        });
        function updateCounterStatus($event_counter, new_count) {
            // first update the status visually...
            if (!$event_counter.hasClass('ui-state-hover')) {
                $event_counter.addClass('ui-state-hover').siblings().removeClass('ui-state-hover');
            }
            // ...then update the numbers
            $('span.count', $event_counter).text(new_count); 
        }
    </script>

    </form>
</body>
</html>
